/*
 * @Author: ૮₍ ˙О˙₎ა
 * @Date: 2023-05-01 10:40:51
 */
import { ajax } from "./ajax.js";

let title =document.querySelector('input[type="text"]')
let content =document.querySelector('#content')

let updateSub=document.querySelector('.updateSub')
let id;
ajax.post('http://localhost/update',null,function(res){
    let obj=res.cNode
    title.value=obj.nodeTitle;
    content.value=obj.nodeContent;
    id=obj._id
    
}) 
updateSub.onclick=function(e){
    let flag=confirm('确定修改吗?')
    if(flag){
        // 如果点击确定
        let updateTitle=title.value;
        let updateContent=content.value;
        
        ajax.post('http://localhost/updateNode',{id,updateTitle,updateContent},function(res){
            window.location.assign('/index')
        })
    }else{
        // 如果点击取消
        window.location.assign('/index')
    }
    e.preventDefault()
}